# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=python-wxpython
_pkgname=wxPython
pkgver=4.2.0
_wxver=3.2.0
_pkgver="${pkgver%.*}"
_post="${pkgver##*.}"
pkgrel=4
epoch=1
pkgdesc='Cross-platform GUI toolkit'
arch=('loong64' 'x86_64')
license=('custom:wxWindows')
url='https://www.wxpython.org'
depends=('wxwidgets-gtk3' 'python-six')
optdepends=('python-pypubsub: Alternative to the deprecated wx.lib.pubsub API')
makedepends=('mesa' 'glu' 'webkit2gtk' 'python-requests' 'python-setuptools' 'python-attrdict' 'sip' 'doxygen' 'waf')
checkdepends=('xorg-server-xvfb' 'python-pytest-forked' 'python-numpy')
source=("https://files.pythonhosted.org/packages/source/w/wxPython/wxPython-$pkgver.tar.gz")
sha512sums=('9ec937a024efb2916403c84382a66004f0c2bb07471246b7de517778309ce459e929eeb59e261f538d3fa077c950628de62e49a3760fbd03ab9ff2114c6f354f')

build() {
  cd $_pkgname-$pkgver

  rm -r sip/{cpp,gen}/* # Recreate sip files with current wxWidgets
  SIP=/usr/bin/sip DOXYGEN=/usr/bin/doxygen WAF=/usr/bin/waf \
  python build.py dox etg --nodoc sip build --use_syswx --release
}

check() {
  cd $_pkgname-$pkgver

  # there are segfaulting tests so --forked ensures we get sensible results
  PYTHONPATH=$PWD xvfb-run pytest --forked unittests || echo "==> WARNING: tests usually fail randomly"
}

package() {
  cd $_pkgname-$pkgver

  python build.py install --destdir="$pkgdir"

  install -Dm 644 LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
  find "$pkgdir/usr/lib" -type f | xargs chmod 644
}
